package com.demo.rocketmq.utils;

import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;

public class RocketMqUtils {

    /**
     * 解析topic，以“:”分割拆分topic和tag
     * @param topic 主题
     * @return left-主题，right-tag
     */
    public static Pair<String, String> splitTopic(String topic) {
        String[] split = topic.split(":", 2);
        String realTopic = split[0];
        String tag;
        if (split.length > 1) {
            tag = split[1];
        } else {
            tag = "";
        }
        return ImmutablePair.of(realTopic, tag);
    }
}
